import sys

import os
from google.appengine.ext.webapp import template

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.dist import use_library
use_library('django', '0.96')
from os import environ
import models
import datetime
import random

ids=["102","103","104","105","106","107","108","109","112","113","114","115","116","117","118","119"]

field=["HPC","Machine Learning","Robotics","TOC","GAME","ANDROID","ELECTRONICS","WEB DEVELOPMENT"]

name=["Compiler Design","Face Detection","QuadraCopter","Travelling Sales Man","Develop a open source","Android Media Player","Andrino Prog","HTML5 Website","Panda 3d Game","Android Battery monitor","Robotic Arm","Google Hacking","Coffee detection ROBOT","FB hacking"]

abst=["qwertyuiop","poiuytrewwq","asdfghjkl","lkjhgfdsa","zxcvbnm","mnbvcxz","blsahahah","blahahaha","blsahahah","blahahaha","blsahahah","blahahaha"]
lang=["pyhton","C","java","c++","perl"]

class MainPage(webapp.RequestHandler,db.Model):
	def get(self):
		c1=db.GqlQuery("SELECT * FROM projectFields")
     		for i in c1:
			i.delete()

		c1=db.GqlQuery("SELECT * FROM projectPool")
     		for i in c1:
			i.delete()
		
		c1=db.GqlQuery("SELECT * FROM projectPool")
		for i in c1:
			self.response.out(i)

		for i in range(0,14):
			project=models.projectPool()
			project.poolprojectid=ids[i]
			project.fieldnames=field[random.randint(0,7)]
			for k in range(0,random.randint(0,2)):
				project.fieldnames=project.fieldnames+","+field[random.randint(0,7)]
			project.projectname=name[i]
			project.abstract=abst[random.randint(0,11)]
			project.languages=lang[random.randint(0,4)]+","+lang[random.randint(0,4)]
			project.put()
			self.response.out.write("Field : "+project.fieldnames+"  ")
			self.response.out.write("Name : "+project.projectname+"  ")
			self.response.out.write("Abstract : "+project.abstract+"  <br>")
		for i in range(0,8):
			p1=models.projectFields()
			p1.fieldname=field[i]
			p1.put()		
			self.response.out.write("Field : "+p1.fieldname+"  ")
	
		"""	
		self.response.out.write("category: "+self.request.get("category")+"<br>")
		self.response.out.write("Lan: ")
		c1=db.GqlQuery("SELECT * FROM languages")
		project.languages=""
     		for i in c1:
			self.response.out.write(i.language+" : "+self.request.get(i.language)+"<br>")
			if self.request.get(i.language)=="yes":
				project.languages=project.languages+i.language+","
		self.response.out.write("<br>category: "+self.request.get("abs")+"<br>")
		self.response.out.write("<br>projectname: "+self.request.get("projectname")+"<br>")
		project.categories=self.request.get("category")
		project.projectname=self.request.get("projectname")
		project.abstract=self.request.get("abs")
		project.confirmed=False
		project.put()
		"""

application = webapp.WSGIApplication([('/', MainPage)],debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

